# Pre-definition.
CPP := g++

DEPS := ../deps
V8_PATH := $(DEPS)/v8
V8_INC := $(V8_PATH)/include
V8_LIB := $(V8_PATH)
CO_PATH := $(DEPS)/pcl
CO_INC := $(CO_PATH)/include
CO_LIB := $(CO_PATH)/pcl/.libs/libpcl.a
COR_PATH := ../src
COR_INC := $(COR_PATH)
COR_LIB := $(COR_PATH)

CFLAGS := -I$(V8_INC) -I$(COR_INC) -fno-rtti -fno-exceptions -O2
LIBS := -L$(V8_LIB) -lv8 -L$(COR_LIB) -ljscoro -lpthread
LIB_OPTION := -Wall

# Test artefects.
TEST_APP := coshell
TEST_OBJS := coshell.o
TEST_BINS := $(TEST_OBJS) $(TEST_APP)

all: $(TEST_APP)

$(TEST_OBJS): coshell.cc
	$(CPP) -c $(CFLAGS) -o $@ $<

$(TEST_APP): $(TEST_OBJS)
	$(CPP) $(LIB_OPTION) $^ -o $@ $(LIBS)

test: all
	./coshell --shell test.js

clean:
	rm -rf $(TEST_BINS)
